home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / HAM_RAD / 3345.ZIP / NKFSA.DOC < prev    next >
Text File  |  1988-06-20  |  22KB  |  522 lines

  1.                 +-------------------------------------------+
  2.                 | N6NKF Real Time Spectrum Analyzer Program |
  3.                 |           Version 0.97  06/19/88          |
  4.                 |   Copyright (c) Franklin Antonio, 1988    |
  5.                 +-------------------------------------------+
  6.  
  7. Required Hardware/Software...
  8.     Computer: Any IBM PC/XT/AT/PS2 or clone 
  9.       Memory: At least 256k memory 
  10.         Graphics: CGA or EGA or VGA graphics board
  11.           System: DOS 2.0 or newer, or OS/2 1.0
  12.    Signal Source: A signal source is required, which can be any one of
  13.           the following...
  14.           a.  A binary disk file of integer data samples
  15.           b.  A formatted disk file of real data samples
  16.               c.  A/D converter on a Dalanco/Spry Model 10 board
  17.           d.  Any A/D converter, with a user-written driver.
  18.  
  19. Recommended Optional Hardware..
  20.     An EGA or VGA graphics board is especially recommended.
  21.     Microsoft mouse, or Mouse-Systems Corp. mouse, or compatible.
  22.  
  23. Things that are NOT required...
  24.       Coprocessor:  8087 or 80287 numeric co-processor is NOT required, but
  25.                         will be used if present.
  26.     DSP Processor:  A DSP board is NOT required.
  27.          ANSI.SYS:  This program does NOT require ANSI.SYS
  28.  
  29. Copyright Statement...
  30.     Copyright (c) Franklin Antonio, 1988.  All Rights Reserved.
  31.     This program is provided at no cost for amateur non-profit use 
  32.     only.  Non-profit distribution of the unmodified program and 
  33.     documentation is allowed.  Commercial use or distribution of 
  34.     this program is prohibited unless license has been obtained 
  35.     from the author.  Copyright is claimed on both the program and
  36.     the visual images the program generates.
  37.  
  38.  
  39.  
  40.  
  41. The remainder of this document consists of the following sections...
  42.  
  43.     0.  Getting Started
  44.     1.  Commands
  45.     2.  Command line options
  46.     3.  NKFSA.INI file options
  47.     4.  Speed of Execution
  48.     5.  Notes re Dalanco-Spry board
  49.     6.  Notes re using file signal source
  50.     7.  Characteristics with various display adapters
  51.     8.  Limitations
  52.     9.  Testing, Bugs, Etc.
  53.        10.  Bibliography
  54.  
  55.  
  56.  
  57.  
  58. Getting Started...
  59. ------------------
  60.  
  61. If you are not already familiar with use of a spectrum analyzer, some of the
  62. controls may seem quite alien.  To gain familiarity with the effect of
  63. windowing, averaging, resolution, etc controls, I suggest you fire up the 
  64. program using the internally generated "demo" signal source.  This signal
  65. consists of a sum of five sinusoids at different amplitudes and frequencies.
  66. One is frequency modulated, and one is amplitude modulated.  To start NKFSA 
  67. with the demo signal source, give the command..
  68.  
  69. >  NKFSA -sd
  70.  
  71. The program will begin set for highest resolution, and a Blackman window.
  72. You may now alter any control settings using either the mouse or keyboard.
  73.  
  74.  
  75.  
  76.  
  77. Commands...
  78. -----------
  79.  
  80. HELP:
  81.     Type ? or click mouse on "HELP" for on-screen help display.
  82.     In some cases, the on-screen help contains additional information.
  83.  
  84. Source:
  85.     Change by clicking mouse on "Sig Src", or type "s".  This selects the
  86.     source of the signal to be analyzed.  Present options are...
  87.  
  88.           1. Demo (a dummy signal provided for demo)
  89.           2. A/D on Dalanco/Spry Model 10 board 
  90.           3. Binary 16-bit Integer Disk file
  91.           4. Formatted Real Disk File
  92.           5. User-written A/D converter driver
  93.  
  94.     As shipped, the Demo signal is the default signal source, because
  95.     that's the only signal source i'm sure everybody has.  
  96.  
  97.     Signal source may also be specified on the command line, and the
  98.     default signal source may be specified in the NKFSA.INI file.  See 
  99.     descriptions of these below.
  100.  
  101.     More info about #2, #3, and #4 above can be found toward the end of 
  102.     this document and in the online help screens.  More info about #5 can 
  103.     be found in the file NKFDRV.DOC.
  104.     
  105.  
  106. Function:
  107.     Change by clicking mouse on "Function", or typing "f".
  108.     This selects the function to be computed & displayed.  Present options
  109.     are "Waveform" (ie like an oscilloscope), "Spectrum" (like a spectrum 
  110.     analyzer), and "Cepstrum".  This program is basically a spectrum anal-
  111.     izer.  The waveform display was added as an afterthought, and is not 
  112.     elaborate.
  113.  
  114. Frequency Resolution:  
  115.     Change by clicking the mouse on "Frq Res" or type "r".  
  116.     This selects the transform size, from 1024 pts to 64 pts, which 
  117.     at 6kHz sample rate corresponds to 5.8 Hz to 93.8 Hz resolution.
  118.     This corresponds to the resolution bandwidth knob on an analog
  119.     spectrum analyzer.
  120.  
  121. Wdw:
  122.     Select the spectral window by clicking on "Wdw:", or typing "w".  
  123.     This selects among three fairly standard windows...
  124.  
  125.     Rectangular     -- Maximum detectability.  -13 db first sidelobe
  126.     Hamming         -- Compromise.             -43 db first sidelobe
  127.     Exact Blackman  -- Lowest Leakage          -68 db first sidelobe
  128.  
  129.     If you are not familiar with the effect of windowing, then you may 
  130.     wish to leave this control set on "Blk" (the Exact Blackman window, 
  131.     which is the default.  There is no corresponding knob on an analog 
  132.     spectrum analyzer.  
  133.  
  134. Avg:
  135.     Selects the # of periodograms which are averaged prior to display.
  136.     Click on "Avg", or type "a".  Options are "off" and "x3".  Averaging 
  137.     increases the stability of a spectral estimate, but may blur rapidly 
  138.     changing spectra.  This corresponds to the video averaging control on 
  139.     an analog spectrum analyzer.
  140.  
  141. Hld:
  142.     Turns the "max hold" feature on and off.  When this switch is on, the
  143.     program remembers the maximum value of the spectrum at each frequency,
  144.     and displays the maximum in a different color.  (only available on EGA
  145.     or VGA displays.)
  146.  
  147. scL:
  148.     Sets the vertical display scale.  In this version, 10db/division
  149.     logrithmic display is the only option.
  150.  
  151. Grat:
  152.     Selects which graticule appears behind the spectrum.  Choices are none,
  153.     dot, line, and grid.  On CGA displays, there is no graticule.
  154.  
  155. EXITing:
  156.     Click on "EXIT", or type "e", or the F10 key.  This corresponds to the
  157.     off switch on an analog spectrum analyzer.
  158.  
  159. Annotation:
  160.     Press the mouse button while the mouse cursor is in the spectrum
  161.     display area, and the frequency and amplitude at that point will be 
  162.     displayed.  I've used the standard mouse cursor, which has it's hot-
  163.     spot located three pixels to the left and one above the mouse tip.  
  164.  
  165. PrtSc:
  166.     Typing the PrtSc key (not Shift-PrtSc) at any time will produce a 
  167.     screen dump to printer.  Epson-like printer command set assumed, and 
  168.     normal DOS printer redirection in effect.  This built-in screen dump
  169.     does not prevent you from using your own screen dump TSR.  See next
  170.     paragraph.
  171.  
  172.     Typing Shift-PrtSc will, as usual, invoke the default DOS print screen
  173.     function, which is not graphics capable, unless you have installed a
  174.     TSR for this purpose.
  175.  
  176.  
  177.  
  178.  
  179. Command Line Options...
  180. -----------------------
  181.  
  182. You may specify any one of the following options on the command line when you 
  183. invoke this program.  Options are case sensitive, so must be typed in lowercase
  184. as shown..
  185.  
  186.     -su    Set signal source to "user-supplied driver"
  187.     -sf{f}    Set signal source to 16-bit integer binary disk file {f}
  188.     -sg{f}    Set signal source to real formatted data file {f}
  189.     -s3    Set signal source to "Dalanco-Spry"
  190.     -sd    Set signal source to "Demo"
  191.  
  192.     -wr    Set window to "rectangular"
  193.     -wh    Set window to "Hamming"
  194.     -wb    Set window to "Blackman"
  195.  
  196.     -sr{n}    Set sample-rate to n samples per second.
  197.  
  198.     -dc    Force use of CGA display mode.
  199.         Normally, this program attempts to automatically use an EGA if 
  200.         available, otherwise it uses CGA.  -dc forces the display to 
  201.         use CGA mode.  I use this for debugging the CGA mode.
  202.  
  203. Example command line with lots of options...
  204.  
  205.     >  nkfsa -dc -sfa:\dir\file.dat -sr6000 -wh
  206.  
  207.  
  208.  
  209.  
  210. NKFSA.INI file options...
  211. -------------------------
  212.  
  213. Each time NKFSA runs, it reads a parameter file, NKFSA.INI.  NKFSA searches 
  214. first in the local directory.  If there is no NKFSA.INI file in the local 
  215. directory, the top level directory on the current drive is searched.  Commands 
  216. in this file specify the colors NKFSA uses (on EGA or VGA displays), and 
  217. default values for many of the parameter settings described above.
  218.  
  219. Documentation on commands in the .INI file is contained in comments in the file
  220. itself.
  221.  
  222.  
  223.  
  224.  
  225. Speed of Execution...
  226. ---------------------
  227. There is a commonly held belief that you can't do real-time signal processing 
  228. without using special DSP chips.  It isn't true!  
  229.  
  230. At it's highest resolution setting, NKFSA computes one spectral estimate in 
  231. about 140 ms (for any integer data source, i.e. any except the "formatted real 
  232. data file")...
  233.  
  234.     times on standard 8 MHz IBM-AT are...
  235.     1024 sample Windowing+FFT                  = 109 ms
  236.     512 frequency Power+Averaging+Logrithm     =  19 ms
  237.     512 frequency display on CGA/EGA/VGA       =  11 ms
  238.                                                     -------
  239.                                            Total   = 139 ms
  240.  
  241.     Max hold display, when enabled, adds another 10 ms.
  242.  
  243. Assuming a sample rate of 6kHz, 1024 samples = 171 ms, so this does run in 
  244. REAL-TIME, examining 100% of the data, for a < 3kHz (voice) bandwidth.  This 
  245. example is for the highest resolution (1024 pts).  At lower resolution 
  246. settings, of course, it goes faster!
  247.  
  248. When running on a slower machine such as an 8088-based PC or XT, the program 
  249. will obviously run more slowly.  Much of the speed can be regained, however, 
  250. by reducing the resolution setting (Frq Res).
  251.  
  252. Examining 100% of the data may seem "only reasonable" (It does to me.), but 
  253. this is an amazingly larger portion of the signal than would be processed by a
  254. traditional analog spectrum analyzer with similar settings on its controls.
  255.  
  256. To put this in perspective, consider how a traditional analog spectrum 
  257. analyzer works.  It estimates the spectum by sweeping a single filter across
  258. the band of interest.  To be comparable to the NKFSA settings described above,
  259. our example analog spectrum analyzer would be sweeping a 5.9 Hz wide filter
  260. over the range [0 Hz, 3 kHz].  This filter can only be in one place at a time,
  261. and that 3 kHz range is 512 times wider than the 5.9 Hz wide analysis filter.  
  262. This means that this single analysis filter spends roughly 1/512th of it's time
  263. at any particular frequency.  This means that at each frequency, the filter is
  264. only able to examine about 1/512th of the input data!
  265.  
  266. Using Fast-Fourier-Transform techniques, digital spectrum analyzers, such as
  267. NKFSA, compute the output of a large number of filters simultaniously.  In the
  268. example above, with 1024 input points, NKFSA would be computing 512 analysis
  269. filters in parallel, every 140ms.  Using 512 filters in parallel, a filter at
  270. each frequency is able to examine all the input data, all of the time.
  271.  
  272. What about sample rates significantly greater than 6kHz?  NKFSA can deal with 
  273. these too, although the computation can no longer examine 100% of the data that
  274. flys by.  In particular, I have used NKFSA with my Dalanco/Spry board at 80kHz 
  275. sample rate, which is the maximum sample rate that boards supports.  As 
  276. described above, NKFSA takes about 140 ms to compute & display one spectral 
  277. estimate based on 1024 points of input.  At 80kHz, 11,200 samples will fly by 
  278. in that 140ms.  This means NKFSA can examine 1024 out of every approx 11,200 
  279. samples.  That's 1/11th of the data.  Still 46 times better than the analog
  280. spectrum analyzer!
  281.  
  282.  
  283.  
  284.  
  285. Notes re Dalanco-Spry Model 10 Board..
  286. --------------------------------------
  287.  
  288. The driver for the D/S board assumes that D/S shared memory is mapped to D000H,
  289. D/S i/o is mapped to 300H, jumper JA is in the "lower" position, and jumper J5 
  290. is in the "ext" position.  
  291.  
  292. NKFSA loads the appropriate software into the D/S board & sets the sample rate.
  293. You don't have to run any ancillary programs.  
  294.  
  295. The D/S board is used only for it's A/D converter.  All calculations are done 
  296. in the PC.
  297.  
  298. The author has no affiliation with Dalanco/Spry.  Someone gave me one of their
  299. boards, so it seemed convenient to write a driver.
  300.  
  301.  
  302.  
  303.  
  304. Notes re Using the "Integer Disk File" Signal Source
  305. ----------------------------------------------------
  306.  
  307. NKFSA assumes that the disk file you specify is a binary file that contains a 
  308. stream of 16-bit numbers, and nothing else (no formatting, record marks, etc).
  309. Each of these 16-bit numbers should be an ordinary 2's-complement number in 
  310. the range [-8192,+8191].  If you write one of these files in a FORTRAN program,
  311. be sure to specify FORM='BINARY' in the open statement.  
  312.  
  313. If the disk file is longer than NKFSA's spectral analysis window, NKFSA will
  314. read thru the file, (like a movie) crunching on blocks of samples in a fashion
  315. similar to the way it operates on samples in real-time.  When it hits the end-
  316. of-file, it repeats.  If the disk file is shorter than the analysis window, 
  317. NKFSA pads the window with zeros, and processes it as usual.
  318.  
  319.  
  320.  
  321.  
  322. Notes on Using the "Real Disk File" Source:
  323. ------------------------------------------
  324.  
  325. The "Real Disk File" source reads a formatted file of numbers in an "e" or "f"
  326. type format (ie like nnn.nnnnnn or nnn.nnnEnnn), one number per line.  If the 
  327. file is shorter than the analysis window, the window is padded with zeros.  
  328. The analysis is done in floating-point arithmetic, and the results are auto-
  329. matically scaled so that the highest point in the spectrum appears at a fixed
  330. point on the screen.
  331.  
  332. This mode was specifically included to evaluate the frequency characteristics 
  333. of FIR filters.  Some versions of the McLellen-Parks FIR filter design program
  334. produce a formatted output file containing the impulse response of the designed
  335. filter in a format as described above.  <<The widely distributed version from 
  336. the old IEEE distribution tape, does not generate such a file.  I have included
  337. the program MACPARK.EXE with this distribution.  This is an updated McLellen-
  338. Parks from the book "Digital Filter Design" by Parks & Burrus.  It has an inter-
  339. active input section which is much easier to use, and it generates an output 
  340. file of impulse response data.  If you need documentation for using MACPARK, 
  341. please buy a copy of Parks & Burrus' excellent book.>>  When the input signal
  342. has a natural beginning and end within the analysis window, as an FIR filter
  343. impulse response does, you should always use a rectangular analysis window.  
  344.  
  345. I have also included a file FIR.DAT which contains an example FIR bandpass 
  346. filter impulse response.  To view the corresponding frequency response...
  347.  
  348.     >  NKFSA -sgFIR.DAT -wr
  349.  
  350. You may also specify a sample rate on the command line, using the -sr option. 
  351. This will make the frequency annotation units on the screen agree with your 
  352. intended use of the filter.
  353.  
  354. Also included in the distribution is the file SUNSPOT.DAT.  This file contains
  355. 184 years of January mean sunspot numbers.  The sample rate is 1 sample/year.  
  356. Because NKFSA doesn't understand sample rates that low, you have to lie.  Tell 
  357. it the sample rate is 1000 samples/second.  Then, scale the resulting anno-
  358. tation in your head.  For example, 500Hz --> 0.5 cycles/year,  100Hz --> 0.1 
  359. cycles/year.  The highest point in the spectrum appears at approximately
  360. 90Hz --> 0.090 cycles/year, and is known as the 11 year sunspot cycle.
  361.  
  362.     > NKFSA -sgSUNSPOT.DAT -sr1000
  363.  
  364. Processing real input is much slower than any other calculation done by NKFSA, 
  365. because it's the only calculation done in floating-point arithmetic.  A 1024 
  366. point calculation takes about 2.5 seconds on an AT w/287, about 3 seconds on a
  367. PC w/8087.
  368.  
  369.  
  370.  
  371.  
  372. Characteristics with Various Display Adapters:
  373. ----------------------------------------------
  374.  
  375. There are unfortunately a great many different display adapters on IBMPC 
  376. systems.  This program is designed to work with many of them.  A brief summary
  377. of what this program supports follows..
  378.  
  379. EGA = Enhanced Graphics Adapter
  380.     The EGA is the lowest-cost adapter that allows full functionality
  381.     of NKFSA. I run this adapter in the 16-color 640x350 graphics mode.
  382.     User can choose which colors NKFSA uses, by specifying them in the
  383.     NKFSA.INI file.
  384.  
  385. VGA = Video Graphics Array (also known as IBM PS/2 Display Adapter)
  386.     I run this adapter in the 16-color 640x350 graphics mode.
  387.     Everything works identical to EGA at the present time.  I am
  388.     considering adding new features to NKFSA which will only be
  389.     accessible to users with VGA cards however.
  390.  
  391. CGA = Color Display Adapter
  392.     I run this adapter in the black & white 640x200 graphics mode.
  393.     Everything is supported on CGA, except that only one spectrum or
  394.     waveform can be displayed in the central window.  (ie the graticule
  395.     and the max-hold feature are invisible).  Of course, the program
  396.     loses much of it's pizzaz when viewed in black & white, but it is
  397.     functional.
  398.  
  399. HGC = Hercules Graphics Card
  400.     I intend to support HGC in a later version of this program.
  401.     It's about half done now.  Should also work on HGC+.  Everything will
  402.     be supported except the max-hold feature.  I will run this adapter in
  403.     its 720x348 black & white graphics mode, so it will have resolution as 
  404.     good as the EGA, but no color.  Meanwhile, Joe Mack, NA3T, has reported
  405.     that he uses NKFSA successfully on a PC with HGC by running a CGA->HGC 
  406.     conversion utility called HGCIBM.  He reports that this slows NKFSA by 
  407.     a factor of 2.
  408.  
  409. HCC = Hercules Color Card
  410.     This card is a clone of the CGA, so should work just like CGA, but
  411.     has not been tested.
  412.  
  413. MDA = Monochrome Display Adapter
  414.     This display adapter doesn't support graphics, so we can't use it
  415.     to display spectra.  If you have two display adapters on your system,
  416.     either MDA+CGA, or MDA+EGA, or MDA+VGA, that's ok.  If you do have a
  417.     two display system, you may fire up NKFSA when either display is 
  418.     current.  If the MDA is the current display when you run NKFSA, it
  419.     will leave the spectrum analyzer picture on the CGA/EGA/VGA when it 
  420.     exits.
  421.  
  422. XXX = Any other display adapter
  423.     I don't know.  I haven't tried it.
  424.  
  425.  
  426.  
  427.  
  428. Limitations:
  429. ------------
  430.  
  431. Probably not presently very compatible with DoubleDOS, TopView, or DesqView, 
  432. or other multi-processing utilities.  No attempt is made to do any special 
  433. programming to be DD or TV or DV friendly.
  434.  
  435. Appears to run ok under OS/2 1.0, in the DOS-compatibility window.
  436.  
  437. Has been tested under DoubleDOS 4.0, and worked ok in two-screen mode, (ie 
  438. DISPLAY=BOTH command in ddconfig.sys file) *IF* i did not load a mouse driver.
  439. If I do load the mouse driver under DoubleDOS, the mouse cursor eats characters
  440. on the display.  The official response from SoftLogic was...
  441.     Msg #  4509 Dated 06-17-88 10:56:34
  442.     From: SYSOP
  443.       To: FRANKLIN ANTONIO
  444.       Re: (R)MICE VS DDOS
  445.     
  446.     Franklin, unfortunately I can offer no other suggestions. I think this
  447.     is about as good as you are going to get running a mouse under 
  448.     DoubleDOS.  jack-sysop
  449.  
  450. I have not tried TopView or DesqView.
  451.  
  452. Command line arguments require at least DOS 3.0 or newer.  All other features 
  453. should work under any version of DOS.
  454.  
  455.  
  456.  
  457.  
  458. Testing, Bugs, Etc:
  459. -------------------
  460.  
  461. I have tried to test this program to a reasonable degree.  Unfortunately, 
  462. users have a variety of hardware and software environments, and this provides 
  463. an incredible testing challenge.  With the aid of Paul Williamson, KB5MU, 
  464. Tom Lafleur, KA6IQA, & Mike Brock, WB6HHV, this program has been tested on..
  465.  
  466. Computers:    A real IBM-AT with 287, a real IBM-7552 "industrial
  467.         computer" without 287, a COMPAQ-386 with 287, a 'turbo' 
  468.         XT clone with an NEC V20 CPU with 8087, a 'turbo' XT clone
  469.         with 8088 CPU without 8087, an Atega 386 with 287.
  470.  
  471. Display Adapters: A real IBM CGA, a real IBM EGA, a Quadram EGA clone,
  472.           a Vega VGA+ clone, an ATI VGA clone.
  473.  
  474. Mice:        A Microsoft serial mouse using MOUSE.COM 6.11 driver, a 
  475.         Microsoft bus mouse using MOUSE.COM 6.13, a Mouse-Systems 
  476.         serial mouse using MSMOUSE.COM 5.03 driver.
  477.  
  478. System:        DOS 3.1, 3.2, 3.3 and the DOS-compatibility window of OS/2 1.0
  479.  
  480. Your environment will undoubtedly be different.  Comments are welcome.  My 
  481. address can be found in the online help text.
  482.  
  483.  
  484. Known problems:
  485.     1.  One user has complained of a "lost mouse clicks" problem.
  486.  
  487.     2.  If certain errors occur while processing (problems with the signal
  488.         source, for example) NKFSA displays a message on the screen which 
  489.         contains the statement "type any character to continue".  If this 
  490.         is a hard error (you forgot to load the TSR A/D driver, or you're 
  491.         having trouble reading a disk file, etc) then the error message 
  492.         will reappear after you type that character (because NKFSA will 
  493.         trying again to read the same signal source).  You can break out of
  494.         this loop by typing the F10 key twice in rapid succession.
  495.  
  496.  
  497.  
  498.  
  499. Bibliography
  500. ------------
  501.  
  502. Technical information on spectrum analysis (from a digital computation point 
  503. of view) can be found in...
  504.  
  505.     R.B.Blackman & J.W.Tukey, The Measurement of Power Spectra,
  506.       Dover Publications, New York, 1958.
  507.       SBN (Paperback edition) = 486-60507-8
  508.  
  509.     A.V.Oppenheim & R.W.Schafer, Digital Signal Processing,
  510.       Prentice-Hall, New Jersey, 1975
  511.       ISBN = 0-13-214635-5
  512.       (chapter 11 -- Power Spectrum Estimation)
  513.  
  514.     S.M.Kay & S.L.Marple, "Spectrum Analysis -- A Modern Perspective",
  515.       Proceedings of the IEEE, V69, #11, Nov. 1981, pp 1380-1419,
  516.       (contains a bibliography with 278 entries!)
  517.  
  518.     C.S.Burrus & T.W.Parks, DFT/FFT and Convolution Algorithms,
  519.       John Wiley & Sons, 1985,
  520.       ISBN 0-471-81932-8
  521.  
  522.